package com.heima.admin.controller.v1;

        import com.heima.admin.entity.AdChannel;
        import com.heima.admin.service.AdChannelService;
        import com.heima.common.dtos.PageResult;
        import com.heima.common.dtos.ResponseResult;
        import com.heima.model.admin.dtos.ChannelDto;
        import io.swagger.annotations.Api;
        import io.swagger.annotations.ApiImplicitParam;
        import io.swagger.annotations.ApiOperation;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.web.bind.annotation.GetMapping;
        import org.springframework.web.bind.annotation.PostMapping;
        import org.springframework.web.bind.annotation.RequestBody;
        import org.springframework.web.bind.annotation.RestController;

        import java.util.List;

@RestController
@Api(tags = "频道管理",description = "频道管理API")
public class ChannelController {

    @Autowired
    private AdChannelService channelService;

    /**
     * 分页查询频道
     * @param dto
     * @return
     */
    @ApiOperation(value = "根据名称分页查询频道列表")
    @ApiImplicitParam(name = "dto", value = "频道请求对象", required = true, dataType = "ChannelDto")
    @PostMapping("/api/v1/channel/list")
    public PageResult<AdChannel> list(@RequestBody ChannelDto dto){

        return channelService.findByPage(dto);
    }

    @GetMapping("/api/v1/channel/channels")
    public ResponseResult<List<AdChannel>> channels(){
        return ResponseResult.ok(channelService.list());
    }
}
